import React, { useEffect } from 'react'
import { useHistory, useLocation } from 'react-router-dom'
    function yztoken(Com){
        return function yztoken(props) {
            let location=useLocation()
            let history=useHistory()
            useEffect(()=>{
                if(location.pathname!=='/login'){
                    let token=localStorage.getItem('token')
                    if(!token){
                        history.push('/login')
                    }
                }
            },)
  return (
    <div>
      <Com {...props}/>
    </div>
  )
}
    }
export default yztoken 
